package com.brillilab.service.core.kit.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.brillilab.dao.mapper.kit.ReagentPrimerAttrMapper;
import com.brillilab.domain.enums.common.IsDeleteEnum;
import com.brillilab.domain.po.kit.Kit;
import com.brillilab.domain.po.kit.ReagentPrimerAttr;
import com.brillilab.service.core.kit.IReagentPrimerAttrService;
@Service
@Transactional
public class ReagentPrimerAttrServiceImpl implements IReagentPrimerAttrService{
	
	@Autowired
	private ReagentPrimerAttrMapper reagentPrimerAttrMapper;	

	@Override
	public ReagentPrimerAttr insert(ReagentPrimerAttr entity) {
		Integer insert = reagentPrimerAttrMapper.insert(entity);
		Assert.isTrue(insert==1, "添加失败");
		return entity;
	}
	
	@Override
	public boolean deleteById(Long id) {
		Integer b = reagentPrimerAttrMapper.deleteById(id);
		return b==1 ? true: false;
	}
	
	@Override
	public boolean updateById(ReagentPrimerAttr entity) {
		entity.setUpdateTime(new Date());
		Integer b = reagentPrimerAttrMapper.updateById(entity);
		return b==1 ? true: false;
	}
	
	@Override
	public ReagentPrimerAttr selectById(Long id) {
		return reagentPrimerAttrMapper.selectById(id);
	}

	@Override
	public List<ReagentPrimerAttr> selectList(Long kitId, Long reagentId) {
		LambdaQueryWrapper<ReagentPrimerAttr> wrapper = new LambdaQueryWrapper<>();
		wrapper.eq(ReagentPrimerAttr::getKitId, kitId);
		wrapper.eq(ReagentPrimerAttr::getReagentId, reagentId);
		return reagentPrimerAttrMapper.selectList(wrapper);
	}
}
